<!DOCTYPE HTML>
<html>
	<head>
		<meta charset="utf-8">
		<title>无标题文档</title>
		<style>
			#div1{
				width:200px;
				height:200px;
				background:red;
			}
		</style>
	</head>
	<body>
		<div id="div1"></div>
	</body>
	<script>
		window.onload=function(){
			var obj = document.getElementById("div1");
			setAndget(obj,"backgroundColor");
		}
		
		function setAndget(obj,name,value){
			if(obj.currentStyle){
				alert(obj.currentStyle[name]);
			}else{
				alert(getComputedStyle(obj,false)[name]);
			}
		}
	</script>
</html>
